import request from '@/utils/request'

// 查询学员考试记录列表
export function listExamRecord(query) {
  return request({
    url: '/jiaxiao/exam/list',
    method: 'get',
    params: query
  })
}

// 查询学员考试记录详细
export function getExamRecord(examId) {
  return request({
    url: '/jiaxiao/exam/' + examId,
    method: 'get'
  })
}

// 新增学员考试记录
export function addExamRecord(data) {
  return request({
    url: '/jiaxiao/exam',
    method: 'post',
    data: data
  })
}

// 修改学员考试记录
export function updateExamRecord(data) {
  return request({
    url: '/jiaxiao/exam',
    method: 'put',
    data: data
  })
}

// 删除学员考试记录
export function delExamRecord(examId) {
  return request({
    url: '/jiaxiao/exam/' + examId,
    method: 'delete'
  })
}

// 登记考试记录（包含业务规则）
export function registerExamRecord(data) {
  return request({
    url: '/jiaxiao/exam/register',
    method: 'post',
    data: data
  })
}

// 查询学员某科目的考试记录
export function getExamRecordsByStudentAndSubject(studentId, subjectId) {
  return request({
    url: '/jiaxiao/exam/student/' + studentId + '/subject/' + subjectId,
    method: 'get'
  })
}

// 查询学员所有科目的考试记录
export function getExamRecordsByStudent(studentId) {
  return request({
    url: '/jiaxiao/exam/student/' + studentId,
    method: 'get'
  })
}

// 检查学员是否可以参加某科目考试
export function canTakeExam(studentId, subjectId) {
  return request({
    url: '/jiaxiao/exam/canTake/' + studentId + '/' + subjectId,
    method: 'get'
  })
}
